<?php
/**
 * Created by PhpStorm.
 * User: chenxiaogang
 * Date: 2017/11/15
 * Time: 下午3:22
 */

namespace User\Model;


use Common\Model\CommonModel;

class Amount extends CommonModel
{
    protected $connection = 'DB_CONFIG2';
    protected $trueTableName = 'system_amount';

    /**
     * @use          [计算逾期费用和逾期后的到期日期]
     * @author       chenxiaogang
     * @param $order    [续期对应的orders这行记录]
     * @param $over_due_days    [要续期的天数]
     * @return array
     */
    public function calOverdueFeesAndDays($order, $over_due_days)
    {
        $amount = xu_amount(array($order));//拿到订单额度配置
        $data = [];
        switch($over_due_days) {
            case '1':
                $data['orther_amount'] = $amount['renewal_fee'];
                $data['orther_time'] = date( 'Y-m-d', strtotime( '+1days' ) );
                break;
            case '2':
                $data['orther_amount'] = $amount['renewal_fee'] * 2;
                $data['orther_time'] = date( 'Y-m-d', strtotime( '+2days' ) );
                break;
            case '6':
                $data['orther_amount'] = $amount['renewal_fee_sev'];//6天的金额跟7天的一样
                $data['orther_time'] = date( 'Y-m-d', strtotime( '+6days' ) );
                break;
            case '7':
                $data['orther_amount'] = $amount['renewal_fee_sev'];
                $data['orther_time'] = date( 'Y-m-d', strtotime( '+7days' ) );
                break;
            //default:
            //    $this->error( '请选择正确的日期!' );
        }
        return $data;
    }

}